﻿using Microsoft.AspNetCore.Mvc;

namespace JNPF.Utils.Controller
{
    /// <summary>
    /// WebAPI基类
    /// 版 本：V3.0.0
    /// 版 权：引迈信息技术有限公司（https://www.jnpfsoft.com）
    /// 作 者：JNPF开发平台组
    /// </summary>
    public abstract class BaseApiController : ControllerBase
    {
        #region 返回Success
        /// <summary>
        /// 返回成功
        /// </summary>
        /// <returns></returns>
        protected virtual ResponseResult Success()
        {
            return new ResponseResult { code = ResponseCode.Success, msg = "Success" };
        }
        /// <summary>
        /// 返回成功
        /// </summary>
        /// <param name="data">数据</param>
        /// <returns></returns>
        protected virtual ResponseResult Success(object data)
        {
            return new ResponseResult { code = ResponseCode.Success, msg = "Success", data = data };
        }
        /// <summary>
        /// 返回成功
        /// </summary>
        /// <param name="message">消息</param>
        /// <returns></returns>
        protected virtual ResponseResult Success(string message)
        {
            return new ResponseResult { code = ResponseCode.Success, msg = message };
        }
        /// <summary>
        /// 返回成功
        /// </summary>
        /// <param name="message">消息</param>
        /// <param name="data">数据</param>
        /// <returns></returns>
        protected virtual ResponseResult Success(string message, object data)
        {
            return new ResponseResult { code = ResponseCode.Success, msg = message, data = data };
        }

        #endregion

        #region 返回Error
        /// <summary>
        /// 返回错误
        /// </summary>
        /// <returns></returns>
        protected virtual ResponseResult Error()
        {
            return new ResponseResult { code = ResponseCode.Fail, msg = "Error" };
        }
        /// <summary>
        /// 返回错误
        /// </summary>
        /// <param name="message">消息</param>
        /// <returns></returns>
        protected virtual ResponseResult Error(string message)
        {
            return new ResponseResult { code = ResponseCode.Fail, msg = message };
        }
        /// <summary>
        /// 返回错误
        /// </summary>
        /// <param name="data">数据</param>
        /// <returns></returns>
        protected virtual ResponseResult Error(object data)
        {
            return new ResponseResult { code = ResponseCode.Fail, msg = "Error", data = data };
        }
        /// <summary>
        /// 返回错误
        /// </summary>
        /// <param name="message">消息</param>
        /// <param name="data">数据</param>
        /// <returns></returns>
        protected virtual ResponseResult Error(string message, object data)
        {
            return new ResponseResult { code = ResponseCode.Fail, msg = message, data = data };
        }
        #endregion

    }
}
